<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Reference</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Duplex</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>


<h2>Modules</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
  <li><a href="../modules/Duplex.Application.html">Duplex.Application</a></li>
  <li><a href="../modules/Duplex.Applications.Effect.html">Duplex.Applications.Effect</a></li>
  <li><a href="../modules/Duplex.Applications.GridPie.html">Duplex.Applications.GridPie</a></li>
  <li><a href="../modules/Duplex.Applications.Hydra.html">Duplex.Applications.Hydra</a></li>
  <li><a href="../modules/Duplex.Applications.Instrument.html">Duplex.Applications.Instrument</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.GridLayout.html">Duplex.Applications.Keyboard.GridLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.Layouts.HarmonicLayout.html">Duplex.Applications.Keyboard.Layouts.HarmonicLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.Layouts.IsomorphicLayout.html">Duplex.Applications.Keyboard.Layouts.IsomorphicLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.Layouts.PianoLayout.html">Duplex.Applications.Keyboard.Layouts.PianoLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.html">Duplex.Applications.Keyboard</a></li>
  <li><a href="../modules/Duplex.Applications.Matrix.html">Duplex.Applications.Matrix</a></li>
  <li><a href="../modules/Duplex.Applications.Metronome.html">Duplex.Applications.Metronome</a></li>
  <li><a href="../modules/Duplex.Applications.MidiActions.Bindings.html">Duplex.Applications.MidiActions.Bindings</a></li>
  <li><a href="../modules/Duplex.Applications.MidiActions.html">Duplex.Applications.MidiActions</a></li>
  <li><a href="../modules/Duplex.Applications.Mixer.html">Duplex.Applications.Mixer</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_group.html">Duplex.Applications.Mlrx.Mlrx_group</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_note.html">Duplex.Applications.Mlrx.Mlrx_note</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_pos.html">Duplex.Applications.Mlrx.Mlrx_pos</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_track.html">Duplex.Applications.Mlrx.Mlrx_track</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.html">Duplex.Applications.Mlrx</a></li>
  <li><a href="../modules/Duplex.Applications.Navigator.html">Duplex.Applications.Navigator</a></li>
  <li><a href="../modules/Duplex.Applications.NotesOnWheels.html">Duplex.Applications.NotesOnWheels</a></li>
  <li><a href="../modules/Duplex.Applications.PatternCursor.html">Duplex.Applications.PatternCursor</a></li>
  <li><a href="../modules/Duplex.Applications.PatternSequence.html">Duplex.Applications.PatternSequence</a></li>
  <li><a href="../modules/Duplex.Applications.Recorder.html">Duplex.Applications.Recorder</a></li>
  <li><a href="../modules/Duplex.Applications.Repeater.html">Duplex.Applications.Repeater</a></li>
  <li><a href="../modules/Duplex.Applications.Rotate.html">Duplex.Applications.Rotate</a></li>
  <li><a href="../modules/Duplex.Applications.StepSequencer.html">Duplex.Applications.StepSequencer</a></li>
  <li><a href="../modules/Duplex.Applications.SwitchConfiguration.html">Duplex.Applications.SwitchConfiguration</a></li>
  <li><a href="../modules/Duplex.Applications.TestPad.html">Duplex.Applications.TestPad</a></li>
  <li><a href="../modules/Duplex.Applications.TrackSelector.html">Duplex.Applications.TrackSelector</a></li>
  <li><a href="../modules/Duplex.Applications.Transport.html">Duplex.Applications.Transport</a></li>
  <li><a href="../modules/Duplex.Applications.UIButtonTest.html">Duplex.Applications.UIButtonTest</a></li>
  <li><a href="../modules/Duplex.Applications.XYPad.html">Duplex.Applications.XYPad</a></li>
  <li><a href="../modules/Duplex.Automation.html">Duplex.Automation</a></li>
  <li><a href="../modules/Duplex.Browser.html">Duplex.Browser</a></li>
  <li><a href="../modules/Duplex.BrowserProcess.html">Duplex.BrowserProcess</a></li>
  <li><a href="../modules/Duplex.Canvas.html">Duplex.Canvas</a></li>
  <li><a href="../modules/Duplex.CanvasPoint.html">Duplex.CanvasPoint</a></li>
  <li><a href="../modules/Duplex.ControlMap.html">Duplex.ControlMap</a></li>
  <li><a href="../modules/Duplex.Device.html">Duplex.Device</a></li>
  <li><a href="../modules/Duplex.Display.html">Duplex.Display</a></li>
  <li><a href="../modules/Duplex.Globals.html">Duplex.Globals</a></li>
  <li><a href="../modules/Duplex.Message.html">Duplex.Message</a></li>
  <li><a href="../modules/Duplex.MessageStream.html">Duplex.MessageStream</a></li>
  <li><strong>Duplex.MidiDevice</strong></li>
  <li><a href="../modules/Duplex.OscClient.html">Duplex.OscClient</a></li>
  <li><a href="../modules/Duplex.OscDevice.html">Duplex.OscDevice</a></li>
  <li><a href="../modules/Duplex.OscVoiceMgr.html">Duplex.OscVoiceMgr</a></li>
  <li><a href="../modules/Duplex.Preferences.html">Duplex.Preferences</a></li>
  <li><a href="../modules/Duplex.ProcessSlicer.html">Duplex.ProcessSlicer</a></li>
  <li><a href="../modules/Duplex.RoamingDSP.html">Duplex.RoamingDSP</a></li>
  <li><a href="../modules/Duplex.Scheduler.html">Duplex.Scheduler</a></li>
  <li><a href="../modules/Duplex.StateController.html">Duplex.StateController</a></li>
  <li><a href="../modules/Duplex.UIButton.html">Duplex.UIButton</a></li>
  <li><a href="../modules/Duplex.UIButtonStrip.html">Duplex.UIButtonStrip</a></li>
  <li><a href="../modules/Duplex.UIComponent.html">Duplex.UIComponent</a></li>
  <li><a href="../modules/Duplex.UIKey.html">Duplex.UIKey</a></li>
  <li><a href="../modules/Duplex.UIKeyPressure.html">Duplex.UIKeyPressure</a></li>
  <li><a href="../modules/Duplex.UILabel.html">Duplex.UILabel</a></li>
  <li><a href="../modules/Duplex.UIPad.html">Duplex.UIPad</a></li>
  <li><a href="../modules/Duplex.UIPitchBend.html">Duplex.UIPitchBend</a></li>
  <li><a href="../modules/Duplex.UISlider.html">Duplex.UISlider</a></li>
  <li><a href="../modules/Duplex.UISpinner.html">Duplex.UISpinner</a></li>
  <li><a href="../modules/Duplex.WidgetHooks.html">Duplex.WidgetHooks</a></li>
  <li><a href="../modules/Duplex.WidgetKeyboard.html">Duplex.WidgetKeyboard</a></li>
  <li><a href="../modules/Duplex.html">Duplex</a></li>
  <li><a href="../modules/main.html">main</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>Duplex.MidiDevice</code></h1>
<p>A generic MIDI device class, providing the ability to send and receive MIDI</p>
<p>
<h3>Changes</h3>

<p>  0.99.5</p>
<pre><code>- Full NRPN support (14 bit messages, absolute and relative modes)
- Input throttling
</code></pre>

<p>  0.99</p>
<pre><code>- Support for MMC (Midi Machine Control) messages over sysex
- Support for 14-bit MIDI pitch bend messages
- Ability to pass unmatched (not just unhandled) messages to Renoise
</code></pre>

<p>  0.98.28</p>
<pre><code>- FIXME MIDI pass-on got ignored when message was not handled by any controls
</code></pre>

<p>  0.98.21</p>
<pre><code>- Fixed: bug when handling MIDI ports that are added/removed while running
</code></pre>

<p>  0.9</p>
<pre><code>- First release
</code></pre>


<p>TODO</p>

<p>  When loading a control-map, parse the parameters and tell this class
  about "special parameter treatments" that we can't decide from here:
  - exempt<em>from</em>throttling (when we want it as fast as possible)
  - exempt<em>from</em>multibyte (when our 7-bit messages should be left alone)</p>


</p>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#__init">__init (display_name, message_stream, port_in, port_out)</a></td>
	<td class="summary">Initialize MidiDevice class</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#open">open ()</a></td>
	<td class="summary">Attempt to open the device MIDI ports</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#release">release ()</a></td>
	<td class="summary">Attempt to release the device MIDI ports</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#midi_callback">midi_callback (message, no_multibyte)</a></td>
	<td class="summary">Invoked when we receive MIDI from device, construct a string identical
 to the <Param> value attribute in order to locate the control-map parameter</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#build_message">build_message (value_str, msg_value, msg_context, msg_channel, msg_is_note_off, bit_depth, midi_msgs)</a></td>
	<td class="summary">Following up on the midi_callback, this method will extract parameters
 from the control-map and construct messages for each of them...</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#sysex_callback">sysex_callback (message)</a></td>
	<td class="summary">Invoked when we receive sysex data from the device</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#send_midi">send_midi (msg)</a></td>
	<td class="summary">Send raw MIDI message to device, optionally dump to console
 (used by send<em>cc, send</em>pitch_bend etc.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#send_cc_message">send_cc_message (number, value, channel, multibyte)</a></td>
	<td class="summary">Send CC message to device</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#send_nrpn_message">send_nrpn_message (number, value, channel, send_only_msb)</a></td>
	<td class="summary">Send NRPN message to device</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#assemble_nrpn_message">assemble_nrpn_message (match_nrpn_num)</a></td>
	<td class="summary">(Re)construct the table of MIDI messages that together form a complete
 NRPN message (compares the provided number with the active NRPN messages)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#send_sysex_message">send_sysex_message (...)</a></td>
	<td class="summary">Send sysex message to device (adding the initial 0xF0 and 0xF7 values)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#send_pitch_bend_message">send_pitch_bend_message (value, channel, mode)</a></td>
	<td class="summary">Send Pitch-Bend message to device.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#send_note_message">send_note_message (key, velocity, channel)</a></td>
	<td class="summary">Send note message to device</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pass_to_renoise">pass_to_renoise (messages)</a></td>
	<td class="summary">Pass unhandled/unmatched message to Renoise?</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#on_idle">on_idle ()</a></td>
	<td class="summary">Idle loop implementation for the MidiDevice class
 main purpose: process (or discard) NRPN messages</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#_note_to_string">_note_to_string (int)</a></td>
	<td class="summary">Convert MIDI note to control-map string, range C--1 to C-9</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#_midi_cc_to_string">_midi_cc_to_string (int)</a></td>
	<td class="summary">Convert MIDI CC value to string, e.g.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#_program_change_to_string">_program_change_to_string (int)</a></td>
	<td class="summary">Convert Program Change value to string, e.g.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#_nrpn_to_string">_nrpn_to_string (num)</a></td>
	<td class="summary">Convert NRPN value to string, e.g.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#extract_midi_cc">extract_midi_cc (str)</a></td>
	<td class="summary">Extract MIDI CC number (range 0-127)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#extract_midi_nrpn">extract_midi_nrpn (str)</a></td>
	<td class="summary">Extract MIDI NRPN number (range 0-16383)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#extract_midi_channel">extract_midi_channel (str)</a></td>
	<td class="summary">Determine channel for the given message (use default port if not specified)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#_create_fingerprint">_create_fingerprint (msg_context, midi_msgs)</a></td>
	<td class="summary">Create MIDI 'fingerprint' for the provided message(s)
 (just enough information to identify the CC/NRPN source)</td>
	</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#self._mb_messages">self._mb_messages</a></td>
	<td class="summary">
<p>(table) table of multibyte messages</p>
<pre><code>[fingerprint]{
  type      = [enum] msg_context
  timestamp = [number]
  channel   = [int]
  num       = [int] (only for CC messages)
  lsb       = [int]
  msb       = [int]
  midi_msgs = [table]
}
</code></pre>
</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self._multibyte_exempted">self._multibyte_exempted</a></td>
	<td class="summary">(table) messages that should not be interpreted as multibyte
 (table is created when parsing control-map)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self._nrpn_messages">self._nrpn_messages</a></td>
	<td class="summary">
<p>(table) table of NRPN messages</p>
<pre><code>{
  timestamp = [number]
  terminated = [bool]
  channel   = [int]
  num_msb   = [int]
  num_lsb   = [int]
  data_msb  = {int]
  data_lsb  = [int]
}
</code></pre>
</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self._nrpn_msb_only">self._nrpn_msb_only</a></td>
	<td class="summary">(table) NRPN messages that only require the MSB part (7-bit)
 (table is created when parsing control-map)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self._throttle_buffer">self._throttle_buffer</a></td>
	<td class="summary">(table) most recently received messages
  [fingerprint] = {</p>
<pre><code>timestamp   = [number]
msg_context = [enum]
msg_channel = [int]
value_str   = [string]
msg_value   = [number]
msg_is_note_off
bit_depth   = [int]
midi_msgs   = [table]
</code></pre>
<p>  }</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self._throttle_exempted">self._throttle_exempted</a></td>
	<td class="summary">(table) messages that should not be throttled
 (table is created when parsing control-map)</td>
	</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#self.port_in">self.port_in</a></td>
	<td class="summary">(string) the MIDI input port</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.port_out">self.port_out</a></td>
	<td class="summary">(string) the MIDI output port</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.midi_in">self.midi_in</a></td>
	<td class="summary">(MidiInputDevice)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.midi_out">self.midi_out</a></td>
	<td class="summary">(MidiOutputDevice)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.default_parameter_mode">self.default_parameter_mode</a></td>
	<td class="summary">(<a href="../modules/Duplex.Globals.html#PARAM_MODE">Duplex.Globals.PARAM_MODE</a>) the default parameter mode</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.throttling_enabled">self.throttling_enabled</a></td>
	<td class="summary">(bool) decide whether to throttle incoming messages
 (the actual threshold is defined in preferences)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.multibyte_enabled">self.multibyte_enabled</a></td>
	<td class="summary">(bool) decide if multibyte (14-bit) support is enabled</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.nrpn_enabled">self.nrpn_enabled</a></td>
	<td class="summary">(bool) decide if NRPN support is enabled</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.terminate_nrpns">self.terminate_nrpns</a></td>
	<td class="summary">(bool) true when we expect a Null value from the device
 after receiving or transmitting a NRPN message
 (enabling this feature will transmit Null values too)
 important: only enable this feature if the device is known to transmit
 these messages (midi bytes 2&amp;3: 0x65,0x7F followed by 0x64,0x7F)</td>
	</tr>
</table>

<br/>
<br/>


    <h2><a name="Functions"></a>Functions</h2>
    <dl class="function">
    <dt>
    <a name = "__init"></a>
    <strong>__init (display_name, message_stream, port_in, port_out)</strong>
    </dt>
    <dd>
    Initialize MidiDevice class


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">display_name</span>
         (string) the friendly name of the device
        </li>
        <li><span class="parameter">message_stream</span>
         (MessageStream) the msg-stream we should attach to
        </li>
        <li><span class="parameter">port_in</span>
         (string) the MIDI input port
        </li>
        <li><span class="parameter">port_out</span>
         (string) the MIDI output port
        </li>
    </ul>





</dd>
    <dt>
    <a name = "open"></a>
    <strong>open ()</strong>
    </dt>
    <dd>
    Attempt to open the device MIDI ports







</dd>
    <dt>
    <a name = "release"></a>
    <strong>release ()</strong>
    </dt>
    <dd>
    Attempt to release the device MIDI ports







</dd>
    <dt>
    <a name = "midi_callback"></a>
    <strong>midi_callback (message, no_multibyte)</strong>
    </dt>
    <dd>
    Invoked when we receive MIDI from device, construct a string identical
 to the <Param> value attribute in order to locate the control-map parameter


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">message</span>
         (Table/MIDIMessage)
        </li>
        <li><span class="parameter">no_multibyte</span>
         (bool) temporarily disable multibyte support
        </li>
    </ul>





</dd>
    <dt>
    <a name = "build_message"></a>
    <strong>build_message (value_str, msg_value, msg_context, msg_channel, msg_is_note_off, bit_depth, midi_msgs)</strong>
    </dt>
    <dd>
    Following up on the midi_callback, this method will extract parameters
 from the control-map and construct messages for each of them...


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value_str</span>
         (string) the control-map value to look for
        </li>
        <li><span class="parameter">msg_value</span>
         (int) the value we recieved
        </li>
        <li><span class="parameter">msg_context</span>
         (enum) (<a href="../modules/Duplex.Globals.html#DEVICE_MESSAGE">Duplex.Globals.DEVICE_MESSAGE</a>)
        </li>
        <li><span class="parameter">msg_channel</span>
         (int) between 1 and 16
        </li>
        <li><span class="parameter">msg_is_note_off</span>
         (bool)
        </li>
        <li><span class="parameter">bit_depth</span>
         (int) 7 or 14 bits
        </li>
        <li><span class="parameter">midi_msgs</span>
         (list of tables, each with three bytes)
        </li>
    </ul>





</dd>
    <dt>
    <a name = "sysex_callback"></a>
    <strong>sysex_callback (message)</strong>
    </dt>
    <dd>
    Invoked when we receive sysex data from the device


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">message</span>
         (table) MIDIMessage
        </li>
    </ul>





</dd>
    <dt>
    <a name = "send_midi"></a>
    <strong>send_midi (msg)</strong>
    </dt>
    <dd>
    Send raw MIDI message to device, optionally dump to console
 (used by send<em>cc, send</em>pitch_bend etc.  methods)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">msg</span>



        </li>
    </ul>





</dd>
    <dt>
    <a name = "send_cc_message"></a>
    <strong>send_cc_message (number, value, channel, multibyte)</strong>
    </dt>
    <dd>
    Send CC message to device


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">number</span>
         (int) 7-bit control-number
        </li>
        <li><span class="parameter">value</span>
         (int) 7 or 14-bit control-value
        </li>
        <li><span class="parameter">channel</span>
         (int) midi channel, between 1-16
        </li>
        <li><span class="parameter">multibyte</span>
         (bool) true when sending a 14-bit value
        </li>
    </ul>





</dd>
    <dt>
    <a name = "send_nrpn_message"></a>
    <strong>send_nrpn_message (number, value, channel, send_only_msb)</strong>
    </dt>
    <dd>
    Send NRPN message to device


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">number</span>
         (int) 14-bit control-number
        </li>
        <li><span class="parameter">value</span>
         (int) 14-bit control-value
        </li>
        <li><span class="parameter">channel</span>
         (int) midi channel, between 1-16
        </li>
        <li><span class="parameter">send_only_msb</span>
         (bool) when sending 7-bit messages
        </li>
    </ul>





</dd>
    <dt>
    <a name = "assemble_nrpn_message"></a>
    <strong>assemble_nrpn_message (match_nrpn_num)</strong>
    </dt>
    <dd>
    (Re)construct the table of MIDI messages that together form a complete
 NRPN message (compares the provided number with the active NRPN messages)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">match_nrpn_num</span>



        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        table or nil
    </ol>




</dd>
    <dt>
    <a name = "send_sysex_message"></a>
    <strong>send_sysex_message (...)</strong>
    </dt>
    <dd>
    Send sysex message to device (adding the initial 0xF0 and 0xF7 values)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">...</span>
         (vararg) values to send, e.g. 0x47, 0x7F, 0x7B,...
        </li>
    </ul>





</dd>
    <dt>
    <a name = "send_pitch_bend_message"></a>
    <strong>send_pitch_bend_message (value, channel, mode)</strong>
    </dt>
    <dd>
    Send Pitch-Bend message to device.
 sending pitch-bend back to a device doesn't make sense when
 you're using a keyboard - it's generally recommended to tag
 the parameter with the "skip_echo" attribute in such a case...
 however, some device setups are different (e.g. Mackie Control)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">value</span>
         (int) the pitch-bend value, 7 bit value
        </li>
        <li><span class="parameter">channel</span>
         (int) the MIDI channel, 1-16 (optional)
        </li>
        <li><span class="parameter">mode</span>
         (string) specify sending mode, e.g. "abs" or "abs_14"
        </li>
    </ul>





</dd>
    <dt>
    <a name = "send_note_message"></a>
    <strong>send_note_message (key, velocity, channel)</strong>
    </dt>
    <dd>
    Send note message to device


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">key</span>
         (int) the MIDI note pitch, 0-127
        </li>
        <li><span class="parameter">velocity</span>
         (int) the MIDI note velocity, 0-127
        </li>
        <li><span class="parameter">channel</span>
         (int) the MIDI channel, 1-16
        </li>
    </ul>





</dd>
    <dt>
    <a name = "pass_to_renoise"></a>
    <strong>pass_to_renoise (messages)</strong>
    </dt>
    <dd>
    Pass unhandled/unmatched message to Renoise? <br/>
 (this is defined in the device settings panel)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">messages</span>
         (table of MIDI messages)
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        bool (true when message was passed)
    </ol>




</dd>
    <dt>
    <a name = "on_idle"></a>
    <strong>on_idle ()</strong>
    </dt>
    <dd>
    Idle loop implementation for the MidiDevice class
 main purpose: process (or discard) NRPN messages







</dd>
    <dt>
    <a name = "_note_to_string"></a>
    <strong>_note_to_string (int)</strong>
    </dt>
    <dd>
    Convert MIDI note to control-map string, range C--1 to C-9


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">int</span>
         (int) the MIDI note key, between 0-120
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        string
    </ol>




</dd>
    <dt>
    <a name = "_midi_cc_to_string"></a>
    <strong>_midi_cc_to_string (int)</strong>
    </dt>
    <dd>
    Convert MIDI CC value to string, e.g.  "CC#%d"


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">int</span>
         (int) the 7-bit CC number
        </li>
    </ul>





</dd>
    <dt>
    <a name = "_program_change_to_string"></a>
    <strong>_program_change_to_string (int)</strong>
    </dt>
    <dd>
    Convert Program Change value to string, e.g.  "Prg#%d"


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">int</span>
         (int) the 7-bit Program Change number
        </li>
    </ul>





</dd>
    <dt>
    <a name = "_nrpn_to_string"></a>
    <strong>_nrpn_to_string (num)</strong>
    </dt>
    <dd>
    Convert NRPN value to string, e.g.  "NRPN#16383"


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">num</span>
         (int) the parameter number (0-16383)
        </li>
    </ul>





</dd>
    <dt>
    <a name = "extract_midi_cc"></a>
    <strong>extract_midi_cc (str)</strong>
    </dt>
    <dd>
    Extract MIDI CC number (range 0-127)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">str</span>
         (string), control-map value attribute (e.g. "CC#10")
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        (int) the MIDI CC number, 0-127
    </ol>




</dd>
    <dt>
    <a name = "extract_midi_nrpn"></a>
    <strong>extract_midi_nrpn (str)</strong>
    </dt>
    <dd>
    Extract MIDI NRPN number (range 0-16383)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">str</span>
         (string), control-map value attribute (e.g. "NRPN#16383")
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        (int) the MIDI NRPN number, 0-16383
    </ol>




</dd>
    <dt>
    <a name = "extract_midi_channel"></a>
    <strong>extract_midi_channel (str)</strong>
    </dt>
    <dd>
    Determine channel for the given message (use default port if not specified)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">str</span>
         (string), control-map value
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        (int) the MIDI channel, 1-16
    </ol>




</dd>
    <dt>
    <a name = "_create_fingerprint"></a>
    <strong>_create_fingerprint (msg_context, midi_msgs)</strong>
    </dt>
    <dd>
    Create MIDI 'fingerprint' for the provided message(s)
 (just enough information to identify the CC/NRPN source)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">msg_context</span>



        </li>
        <li><span class="parameter">midi_msgs</span>



        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        string
    </ol>




</dd>
</dl>
    <h2><a name="Tables"></a>Tables</h2>
    <dl class="function">
    <dt>
    <a name = "self._mb_messages"></a>
    <strong>self._mb_messages</strong>
    </dt>
    <dd>

<p>(table) table of multibyte messages</p>
<pre><code>[fingerprint]{
  type      = [enum] msg_context
  timestamp = [number]
  channel   = [int]
  num       = [int] (only for CC messages)
  lsb       = [int]
  msb       = [int]
  midi_msgs = [table]
}
</code></pre>








</dd>
    <dt>
    <a name = "self._multibyte_exempted"></a>
    <strong>self._multibyte_exempted</strong>
    </dt>
    <dd>
    (table) messages that should not be interpreted as multibyte
 (table is created when parsing control-map)







</dd>
    <dt>
    <a name = "self._nrpn_messages"></a>
    <strong>self._nrpn_messages</strong>
    </dt>
    <dd>

<p>(table) table of NRPN messages</p>
<pre><code>{
  timestamp = [number]
  terminated = [bool]
  channel   = [int]
  num_msb   = [int]
  num_lsb   = [int]
  data_msb  = {int]
  data_lsb  = [int]
}
</code></pre>








</dd>
    <dt>
    <a name = "self._nrpn_msb_only"></a>
    <strong>self._nrpn_msb_only</strong>
    </dt>
    <dd>
    (table) NRPN messages that only require the MSB part (7-bit)
 (table is created when parsing control-map)







</dd>
    <dt>
    <a name = "self._throttle_buffer"></a>
    <strong>self._throttle_buffer</strong>
    </dt>
    <dd>
    (table) most recently received messages
  [fingerprint] = {</p>
<pre><code>timestamp   = [number]
msg_context = [enum]
msg_channel = [int]
value_str   = [string]
msg_value   = [number]
msg_is_note_off
bit_depth   = [int]
midi_msgs   = [table]
</code></pre>
<p>  }







</dd>
    <dt>
    <a name = "self._throttle_exempted"></a>
    <strong>self._throttle_exempted</strong>
    </dt>
    <dd>
    (table) messages that should not be throttled
 (table is created when parsing control-map)







</dd>
</dl>
    <h2><a name="Fields"></a>Fields</h2>
    <dl class="function">
    <dt>
    <a name = "self.port_in"></a>
    <strong>self.port_in</strong>
    </dt>
    <dd>
    (string) the MIDI input port







</dd>
    <dt>
    <a name = "self.port_out"></a>
    <strong>self.port_out</strong>
    </dt>
    <dd>
    (string) the MIDI output port







</dd>
    <dt>
    <a name = "self.midi_in"></a>
    <strong>self.midi_in</strong>
    </dt>
    <dd>
    (MidiInputDevice)







</dd>
    <dt>
    <a name = "self.midi_out"></a>
    <strong>self.midi_out</strong>
    </dt>
    <dd>
    (MidiOutputDevice)







</dd>
    <dt>
    <a name = "self.default_parameter_mode"></a>
    <strong>self.default_parameter_mode</strong>
    </dt>
    <dd>
    (<a href="../modules/Duplex.Globals.html#PARAM_MODE">Duplex.Globals.PARAM_MODE</a>) the default parameter mode







</dd>
    <dt>
    <a name = "self.throttling_enabled"></a>
    <strong>self.throttling_enabled</strong>
    </dt>
    <dd>
    (bool) decide whether to throttle incoming messages
 (the actual threshold is defined in preferences)







</dd>
    <dt>
    <a name = "self.multibyte_enabled"></a>
    <strong>self.multibyte_enabled</strong>
    </dt>
    <dd>
    (bool) decide if multibyte (14-bit) support is enabled







</dd>
    <dt>
    <a name = "self.nrpn_enabled"></a>
    <strong>self.nrpn_enabled</strong>
    </dt>
    <dd>
    (bool) decide if NRPN support is enabled







</dd>
    <dt>
    <a name = "self.terminate_nrpns"></a>
    <strong>self.terminate_nrpns</strong>
    </dt>
    <dd>
    (bool) true when we expect a Null value from the device
 after receiving or transmitting a NRPN message
 (enabling this feature will transmit Null values too)
 important: only enable this feature if the device is known to transmit
 these messages (midi bytes 2&amp;3: 0x65,0x7F followed by 0x64,0x7F)







</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.2</a></i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
